package com.swanclouds.redfish.chassis.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.chassis.PCIeDevices;

import java.util.Map;


/**
 * @author 张立强 
 */
public class PCIeDevicesModel implements PCIeDevices {

    /**指定PCIe设备资源的访问路径**/
    @JsonProperty("@odata.id")
    private String dataId;

    /**指定PCIe设备资源模型的OData描述信息**/
    @JsonProperty("@odata.context")
    private String context;

    /**指定PCIe设备资源的类型**/
    @JsonProperty("@odata.type")
    private String type;

    /**指定PCIe设备资源ID**/
    @JsonProperty("Id")
    private String id;

    /**指定PCIe设备资源名称**/
    @JsonProperty("Name")
    private String name;

    /**指定PCIe设备的型号**/
    @JsonProperty("Model")
    private String model;

    /**指定PCIe设备的序列号**/
    @JsonProperty("SerialNumber")
    private String serialNumber;

    /**指定PCIe设备的固件版本**/
    @JsonProperty("FirmwareVersion")
    private String firmwareVersion;

    /**指定PCIe设备的描述**/
    @JsonProperty("Description")
    private String description;

    /**指定PCIe设备的生成厂商**/
    @JsonProperty("Manufacturer")
    private String manufacturer;

    /**指定PCIe设备的状态**/
    @JsonProperty("Status")
    private StatusModel status;

    /**厂商自定义信息**/
    @JsonProperty("Oem")
    private Map<String, Object> oem;


    @Override
    public String getDataId() {
        return this.dataId;
    }

    @Override
    public String getContext() {
        return this.context;
    }

    @Override
    public String getType() {
        return this.type;
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public String getModel() {
        return model;
    }

    public StatusModel getStatus() {
        return status;
    }

    @JsonRootName("Status")
    public static class StatusModel implements PCIeDevices.Status {

        @JsonProperty("State")
        private String state;
        /**
         * PCIe设备使能状态
         *
         * @return state
         */
        @Override
        public String getState() {
            return this.state;
        }

        @JsonProperty("Health")
        private String health;
        /**
         * PCIe设备健康状态
         *
         * @return health
         */
        @Override
        public String getHealth() {
            return this.health;
        }

        @JsonProperty("Severity")
        private String severity;
        /**
         * PCIe设备的自定义健康状态
         *
         * @return severity
         */
        @Override
        public String getSeverity() {
            return this.severity;
        }

        @Override
        public String toString() {
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                return objectMapper.writeValueAsString(this);
            } catch (JsonProcessingException e) {
            }
            return "StatusModel {" +
                    "state='" + state + '\'' +
                    ", health='" + health + '\'' +
                    ", severity='" + severity + '\'' +
                    '}';
        }
    }

    public Map<String, Object> getOem() {
        return oem;
    }

    public String getSerialNumber() {
        return serialNumber;
    }

    public String getFirmwareVersion() {
        return firmwareVersion;
    }

    public String getDescription() {
        return description;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "PCIeDevicesModel{" +
                ", dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", Id='" + id + '\'' +
                ", Name='" + name + '\'' +
                ", Model='" + model + '\'' +
                ", Description='" + description + '\'' +
                ", Manufacturer='" + manufacturer + '\'' +
                ", SerialNumber='" + serialNumber + '\'' +
                ", Status='" + status + '\'' +
                ", Oem='" + oem + '\'' +
                '}';
    }

}
